<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	  layout:decorate="~{/layout}">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>订单管理</title>

		<div th:replace="commons/css/css_personal::personal_css"></div>
		<link th:href="@{/personal/css/orstyle.css}" rel="stylesheet" type="text/css">
		<div th:replace="commons/css/css_header_footer :: public_css1"></div>
		<div th:replace="commons/js/js_header_footer :: public_js1"></div>
		<div th:replace="commons/js/js_personal::personal_js"></div>
	</head>

	<body>
		<!--头 -->
		<div th:replace="commons/header::public_header"></div>

		<!-- Preloader -->
		<div id="preloader" class="preloader">
			<div class="loader-cube">
				<div class="loader-cube__item1 loader-cube__item"></div>
				<div class="loader-cube__item2 loader-cube__item"></div>
				<div class="loader-cube__item4 loader-cube__item"></div>
				<div class="loader-cube__item3 loader-cube__item"></div>
			</div>
		</div>
		<!-- End Preloader -->

			<b class="line"></b>
		<div class="center">
			<div class="col-main">
				<div class="main-wrap">

					<div class="user-order">

						<!--标题 -->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">订单管理</strong> / <small>Order</small></div>
						</div>
						<hr/>

						<div class="am-tabs am-tabs-d2 am-margin" data-am-tabs>

							<ul class="am-avg-sm-5 am-tabs-nav am-nav am-nav-tabs">
								<li class="am-active"><a href="#tab1">所有订单</a></li>
								<li><a href="#tab2">待付款</a></li>
								<li><a href="#tab3">待发货</a></li>
								<li><a href="#tab4">待收货</a></li>
								<li><a href="#tab5">待评价</a></li>
							</ul>

							<div class="am-tabs-bd">
								<!--用户中心所有订单-->
								<div class="am-tab-panel am-fade am-in am-active" id="tab1">
									<div th:replace="commons/personal_footer::personal_indent"></div>
									<div class="order-main">
										<div class="order-list">

											<!--交易成功-->
											<div class="order-status5" name="parent" th:each="indents : ${indentList}">
												<div name="child">
												<div class="order-title">
													<div class="dd-num">订单编号：<a href="javascript:;"><span name="orderid" th:text="${indents.orderid}"></span></a></div>
													<span th:text="'成交时间：'+${#dates.format(indents.ordertime, 'yyyy-MM-dd HH:mm')}"></span>
												</div>
												<div class="order-content">
													<div class="order-left">
														<ul class="item-list" th:each="goods : ${indents.goodsInfo}">
															<li class="td td-item">
																<div class="item-pic">
																	<a href="#" class="J_MakePoint">
																		<img th:src="@{/pictures/}+${goods.imagePaths[0].path}" class="itempic J_ItemImg">
																	</a>
																</div>
																<div class="item-info">
																	<div class="item-basic-info">
																		<a href="#">
																			<p th:text="${goods.goodsname}"></p>
																			<p class="info-little" th:text="'商品分类：'+${goods.cateName}"></p>
																			<p class="info-little" th:text="${goods.detailcate}"></p>
																		</a>
																	</div>
																</div>
															</li>
															<li class="td td-price">
																<div class="item-price">
																	<span th:text="${goods.price}"></span>
																</div>
															</li>
															<li class="td td-number">
																<div class="item-number">
																	<span>×</span><span th:text="${goods.indentGoodsNum}"></span>
																</div>
															</li>
															<li class="td td-operation">
																<div class="item-operation">

																</div>
															</li>
														</ul>
													</div>
													<div class="order-right">
														<li class="td td-amount">
															<div class="item-amount">
																<span th:text="${indents.newprice}"></span>
																<p>含运费：<span>10.00</span></p>
															</div>
														</li>
														<div class="move-right">
															<li class="td td-status">
																<div class="item-status">
																	<div th:if="${indents.iscomplete}==true">
																		<p class="Mystatus"  th:text="交易成功"></p>
																	</div>
																	<div th:if="${indents.iscomplete}==false">
																		<div th:if="${indents.isreceive}==true">
																			<p class="Mystatus"  th:text="买家已收货"></p>
																		</div>
																		<div th:if="${indents.isreceive}==false">
																			<div th:if="${indents.issend}==true">
																				<p class="Mystatus" th:text="卖家已发货"></p>
																			</div>
																			<div th:if="${indents.issend}==false">
																				<div th:if="${indents.ispay}==true">
																					<p class="Mystatus"  th:text="买家已付款"></p>
																				</div>
																				<div th:if="${indents.ispay}==false">
																					<p class="Mystatus"  th:text="等待买家付款"></p>
																				</div>
																			</div>
																		</div>
																	</div>
																	<p class="order-info"><a href="orderinfo.html">订单详情</a></p>
																	<p class="order-info"><a href="logistics.html">查看物流</a></p>
																</div>
															</li>
															<li class="td td-change">
																<div class="am-btn am-btn-danger anniu" name="deleteIndent">删除订单</div>
															</li>
														</div>
													</div>
												</div>
												</div>
											</div>

										</div>

									</div>

								</div>
								<!--用户中心未付款订单-->
								<div class="am-tab-panel am-fade" id="tab2">
									<div th:replace="commons/personal_footer::personal_indent"></div>

									<div class="order-main">
										<div class="order-list">
											<div class="order-status1" th:each="indents : ${indentList}">
												<div th:if="${indents.ispay}==false">
												<div class="order-title">
													<div class="dd-num">订单编号：<a href="javascript:;"><span th:text="${indents.orderid}"></span></a></div>
													<span th:text="'成交时间：'+${#dates.format(indents.ordertime, 'yyyy-MM-dd HH:mm')}"></span>
												</div>
												<div class="order-content">
													<div class="order-left">
														<ul class="item-list" th:each="goods : ${indents.goodsInfo}">
															<li class="td td-item">
																<div class="item-pic">
																	<a href="#" class="J_MakePoint">
																		<img th:src="@{/pictures/}+${goods.imagePaths[0].path}" class="itempic J_ItemImg">
																	</a>
																</div>
																<div class="item-info">
																	<div class="item-basic-info">
																		<a href="#">
																			<p th:text="${goods.goodsname}"></p>
																			<p class="info-little" th:text="'商品分类：'+${goods.cateName}"></p>
																			<p class="info-little" th:text="${goods.detailcate}"></p>
																		</a>
																	</div>
																</div>
															</li>
															<li class="td td-price">
																<div class="item-price">
																	<span th:text="${goods.price}"></span>
																</div>
															</li>
															<li class="td td-number">
																<div class="item-number">
																	<span>×</span><span th:text="${goods.indentGoodsNum}"></span>
																</div>
															</li>
															<li class="td td-operation">
																<div class="item-operation">

																</div>
															</li>
														</ul>
													</div>
													<div class="order-right">
														<li class="td td-amount">
															<div class="item-amount">
																<span th:text="${indents.newprice}"></span>
																<p>含运费：<span>10.00</span></p>
															</div>
														</li>
														<div class="move-right">
															<li class="td td-status">
																<div class="item-status">
																	<p class="Mystatus">等待买家付款</p>
																	<p class="order-info"><a href="#">取消订单</a></p>
																</div>
															</li>
															<li class="td td-change">
																<a th:href="'/checkout/'+${indents.orderid}+'/' + ${indents.newprice}">
																<div class="am-btn am-btn-danger anniu">
																	一键支付</div></a>
															</li>
														</div>
													</div>

												</div>
												</div>
											</div>
										</div>

									</div>
								</div>
								<!--用户中心未发货订单-->
								<div class="am-tab-panel am-fade" id="tab3">
									<div th:replace="commons/personal_footer::personal_indent"></div>

									<div class="order-main">
										<div class="order-list">
											<div class="order-status2" th:each="indents : ${indentList}">
												<div th:if="${indents.ispay}==true and ${indents.issend}==false">
												<div class="order-title">
													<div class="dd-num">订单编号：<a href="javascript:;"><span th:text="${indents.orderid}"></span></a></div>
													<span th:text="'成交时间：'+${#dates.format(indents.ordertime, 'yyyy-MM-dd HH:mm')}"></span>
												</div>
												<div class="order-content">
													<div class="order-left">
														<ul class="item-list" th:each="goods : ${indents.goodsInfo}">
															<li class="td td-item">
																<div class="item-pic">
																	<a href="#" class="J_MakePoint">
																		<img th:src="@{/pictures/}+${goods.imagePaths[0].path}" class="itempic J_ItemImg">
																	</a>
																</div>
																<div class="item-info">
																	<div class="item-basic-info">
																		<a href="#">
																			<p th:text="${goods.goodsname}"></p>
																			<p class="info-little" th:text="'商品分类：'+${goods.cateName}"></p>
																			<p class="info-little" th:text="${goods.detailcate}"></p>
																		</a>
																	</div>
																</div>
															</li>
															<li class="td td-price">
																<div class="item-price">
																	<span th:text="${goods.price}"></span>
																</div>
															</li>
															<li class="td td-number">
																<div class="item-number">
																	<span>×</span><span th:text="${goods.indentGoodsNum}"></span>
																</div>
															</li>
															<li class="td td-operation">
																<div class="item-operation">
																	<a href="refund.html">退款</a>
																</div>
															</li>
														</ul>
													</div>
													<div class="order-right">
														<li class="td td-amount">
															<div class="item-amount">
																<span th:text="${indents.newprice}"></span>
																<p>含运费：<span>10.00</span></p>
															</div>
														</li>
														<div class="move-right">
															<li class="td td-status">
																<div class="item-status">
																	<p class="Mystatus">买家已付款</p>
																	<p class="order-info"><a href="orderinfo.html">订单详情</a></p>
																</div>
															</li>
															<li class="td td-change">
																<div class="am-btn am-btn-danger anniu">
																	提醒发货</div>
															</li>
														</div>
													</div>
												</div>
												</div>
											</div>
										</div>
									</div>
								</div>

								<!--用户中心待收货订单-->
								<div class="am-tab-panel am-fade" id="tab4">
									<div th:replace="commons/personal_footer::personal_indent"></div>

									<div class="order-main">
										<div class="order-list">
											<div class="order-status3" name="parent" th:each="indents : ${indentList}">
												<div th:if="${indents.ispay}==true and ${indents.issend}==true and ${indents.isreceive}==false">
													<div name="child">
														<div class="order-title">
															<div class="dd-num">订单编号：<a href="javascript:;">><span name="orderid" th:text="${indents.orderid}"></span></a></div>
															<span th:text="'成交时间：'+${#dates.format(indents.ordertime, 'yyyy-MM-dd HH:mm')}"></span>
														</div>
														<div class="order-content">
															<div class="order-left">
																<ul class="item-list" th:each="goods : ${indents.goodsInfo}">
																	<li class="td td-item">
																		<div class="item-pic">
																			<a href="#" class="J_MakePoint">
																				<img th:src="@{/pictures/}+${goods.imagePaths[0].path}" class="itempic J_ItemImg">
																			</a>
																		</div>
																		<div class="item-info">
																			<div class="item-basic-info">
																				<a href="#">
																					<p th:text="${goods.goodsname}"></p>
																					<p class="info-little" th:text="'商品分类：'+${goods.cateName}"></p>
																					<p class="info-little" th:text="${goods.detailcate}"></p>
																				</a>
																			</div>
																		</div>
																	</li>
																	<li class="td td-price">
																		<div class="item-price">
																			<span th:text="${goods.price}"></span>
																		</div>
																	</li>
																	<li class="td td-number">
																		<div class="item-number">
																			<span>×</span><span th:text="${goods.indentGoodsNum}"></span>
																		</div>
																	</li>
																	<li class="td td-operation">
																		<div class="item-operation">
																			<a href="refund.html">退款/退货</a>
																		</div>
																	</li>
																</ul>
															</div>
															<div class="order-right">
																<li class="td td-amount">
																	<div class="item-amount">
																		<span th:text="${indents.newprice}"></span>
																		<p>含运费：<span>10.00</span></p>
																	</div>
																</li>
																<div class="move-right">
																	<li class="td td-status">
																		<div class="item-status">
																			<p class="Mystatus">卖家已发货</p>
																			<p class="order-info"><a href="orderinfo.html">订单详情</a></p>
																			<p class="order-info"><a href="logistics.html">查看物流</a></p>
																			<p class="order-info"><a href="#">延长收货</a></p>
																		</div>
																	</li>
																	<li class="td td-change">
																		<div class="am-btn am-btn-danger anniu" name="confirmRev">确认收货</div>
																	</li>
																</div>
															</div>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
								<!--用户中心待评价订单-->
								<div class="am-tab-panel am-fade" id="tab5">
									<div th:replace="commons/personal_footer::personal_indent"></div>

									<div class="order-main">
										<div class="order-list">
											<!--不同状态的订单	-->
										<div class="order-status4" th:each="indents : ${indentList}">
											<div th:if="${indents.ispay}==true and ${indents.issend}==true and ${indents.isreceive}==true and ${indents.iscomplete}==false">
												<div name="child">
													<div class="order-title">
														<div class="dd-num">订单编号：<a href="javascript:;"><span th:text="${indents.orderid}"></span></a></div>
														<span th:text="'成交时间：'+${#dates.format(indents.ordertime, 'yyyy-MM-dd HH:mm')}"></span>
													</div>
													<div class="order-content">
														<div class="order-left">
															<ul class="item-list" th:each="goods : ${indents.goodsInfo}">
																<li class="td td-item">
																	<div class="item-pic">
																		<a href="#" class="J_MakePoint">
																			<img th:src="@{/pictures/}+${goods.imagePaths[0].path}" class="itempic J_ItemImg">
																		</a>
																	</div>
																	<div class="item-info">
																		<div class="item-basic-info">
																			<a href="#">
																				<p th:text="${goods.goodsname}"></p>
																				<p class="info-little" th:text="'商品分类：'+${goods.cateName}"></p>
																				<p class="info-little" th:text="${goods.detailcate}"></p>
																			</a>
																		</div>
																	</div>
																</li>
																<li class="td td-price">
																	<div class="item-price">
																		<span th:text="${goods.price}"></span>
																	</div>
																</li>
																<li class="td td-number">
																	<div class="item-number">
																		<span>×</span><span th:text="${goods.indentGoodsNum}"></span>
																	</div>
																</li>
																<li class="td td-operation">
																	<div class="item-operation">
																		<a href="refund.html">退款/退货</a>
																	</div>
																</li>
															</ul>

														</div>
														<div class="order-right">
															<li class="td td-amount">
																<div class="item-amount">
																	<span th:text="${indents.newprice}"></span>
																	<p>含运费：<span>10.00</span></p>
																</div>
															</li>
															<div class="move-right">
																<li class="td td-status">
																	<div class="item-status">
																		<p class="Mystatus">交易成功</p>
																		<p class="order-info"><a href="orderinfo.html">订单详情</a></p>
																		<p class="order-info"><a href="logistics.html">查看物流</a></p>
																	</div>
																</li>
																<li class="td td-change">
																	<a th:href="@{'/comments/evaluation?orderid='+${indents.orderid}}">
                                                                        <div class="am-btn am-btn-danger anniu">评价商品</div>
																	</a>
																</li>
															</div>
														</div>
													</div>
												</div>
											</div>
										</div>
										</div>

									</div>

								</div>
							</div>

						</div>
					</div>
				</div>
				<!--底部-->
				<div th:replace="commons/personal_footer::personal_footer"></div>
			</div>
			<div th:replace="commons/personal_footer::personal_menu"></div>
		</div>

	</body>

<script>
    $(document).ready(function () {
        changeStatus();
    })

    function changeStatus() {
        $("#li_oreder").addClass("active");
    }

	//删除订单
	$("[name='deleteIndent']").click(function () {
	    var orderid = $(this).parents("[name='parent']").find("[name='orderid']").text();
        var indent={};
        indent.orderid = parseInt(orderid);
		var index =$(this).parents("[name='child']");
        swal({
                title:'您是否要删除?',
                text: '删除后无法恢复订单信息',
                type:'warning',
                showCancelButton:true,
                confirmButtonText: '删除',
                cancelButtonText: '返回',
                closeOnConfirm: false,
                closeOnCancel: false
            },
            function (isConfirm) {
                if(isConfirm){
                    $.ajax({
                        type:"POST",
                        url: "/users/deleteIndent",
                        data: indent,
                        dataType:"json",
                        success:function (result) {
                            swal({
                                title:result.msg,
                                type:'success'
                            });
                            index.hide();
                        },
                        error:function () {
                            swal("删除失败");
                        }
                    });
                }else if(isConfirm == false){
                    swal(
                        '已取消',
                        'error'
                    );
                }
            });
    });


	//用户确认收货
	$("[name='confirmRev']").click(function () {
        var orderid=$(this).parents("[name='parent']").find("[name='orderid']").text();
        var indent={};
        indent.orderid = orderid;
        var index =$(this).parents("[name='child']");

        swal({
                title:'您是否收到商品',
                text: '确认后更新订单信息',
                type:'warning',
                showCancelButton:true,
                confirmButtonText: '确认',
                cancelButtonText: '返回',
                closeOnConfirm: false,
                closeOnCancel: false
            },
            function (isConfirm) {
                if(isConfirm){
                    $.ajax({
                        type:'POST',
                        url: '/users/confirmRev',
                        data: indent,
                        dataType:'json',
                        success:function (result) {
                            swal({
								title: result.msg,
								type:'success'
							});
                            index.hide();
                            location.reload();
                        },
                        error:function () {
                            swal("更新失败");
                        }
                    });
                }else if(isConfirm == false){
                    swal(
                        '已取消',
                        'error'
                    );
                }
            });

    });

	//用户评价


</script>


</html>